#!/bin/bash

if [ $(id -u) = 0 ]
then
   echo "This script must not be run as root" 1>&2
   exit
fi

ROOT_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd);
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}");
NAME="${SCRIPT_NAME%.*}"	# cut extension
NAME="${NAME#*.}"			# cut number

TTS_PATH=$ROOT_PATH/$NAME

### TTS ###

echo Add tts virtual 32-bit drive...

playonlinux

# Microsoft Speech Platform

cp $TTS_PATH/SpeechPlatformRuntime.msi "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/"
WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine msiexec -i "c:/Program Files/SpeechPlatformRuntime.msi" /passive
rm -f "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/SpeechPlatformRuntime.msi"

# Russian voice

cp $TTS_PATH/MSSpeech_TTS_ru-RU_Elena.msi "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/"
WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine msiexec -i "c:/Program Files/MSSpeech_TTS_ru-RU_Elena.msi" /passive
rm -f "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/MSSpeech_TTS_ru-RU_Elena.msi"


# sapi5 engine

#WINEPREFIX=~/.PlayOnLinux/wineprefix/tts winetricks speechsdk

# Russian voice

#cd /tmp
#wget -O setup.exe https://rhvoice.org/download/RHVoice-voice-Russian-Anna-v4.1.2010.15-setup.exe
#cp setup.exe "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/"
#WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine "c:/Program Files/setup.exe" /S
#rm -f "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/setup.exe"
#rm -f setup.exe
#cd "$ROOT_PATH"

#cd /tmp
#wget -O voice.zip "https://rhvoice.su/downloads/?voice=tatiana&type=sapi"
#unzip -o voice.zip -d "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/_voice"
#SETUP=$(ls "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/_voice")
#WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine "c:/Program Files/_voice/$SETUP" /S
#rm -f -r "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/_voice"
#rm -f voice.zip
#cd "$ROOT_PATH"

# Balabolka

#cd /tmp
#wget http://www.cross-plus-a.com/balabolka_portable.zip
#unzip -o balabolka_portable.zip -d "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files"
#rm -f balabolka_portable.zip
#cd "$ROOT_PATH"

cd /tmp
wget http://www.cross-plus-a.com/balabolka.zip
unzip -o balabolka.zip -d "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/_balabolka"
WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine "c:/Program Files/_balabolka/setup.exe"
rm -f -r "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/_balabolka"
rm -f balabolka.zip
cd "$ROOT_PATH"

# Check voices installed

cd /tmp
wget http://www.cross-plus-a.com/balcon.zip
unzip -o balcon.zip -d "$HOME/.PlayOnLinux/wineprefix/tts/drive_c/Program Files/balcon"
rm -f balcon.zip
cd "$ROOT_PATH"

echo Check voices installed...

WINEPREFIX=~/.PlayOnLinux/wineprefix/tts wine "c:/Program Files/balcon/balcon.exe" -l





